<template>
    <div>
        <el-container>
            <el-header class="header-all">
                <!-- 查询区域 -->
                <div style="display: inline;">
                    资产操作：
                    <el-select v-model="value" placeholder="请选择">
                        <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                        </el-option>
                    </el-select>
                    &nbsp;&nbsp;&nbsp;&nbsp;资产名称：
                    <el-input v-model="input" style="width: 200px;"></el-input>
                    &nbsp;&nbsp;&nbsp;&nbsp;批次编号：
                    <el-input v-model="input" style="width: 200px;"></el-input>&nbsp;&nbsp;
                    <el-button type="primary" class="but-select" @click="select">搜索</el-button>
                </div>
            </el-header>
            <el-main>
                <el-table :data="normalList1" v-loading="loading" ref="normalList1" stripe>
                    <el-table-column prop="assetscode" width="160px" label="资产编号" align="center"></el-table-column>
                    <el-table-column prop="assetsnamecn" width="220px" label="资产名称" align="center"></el-table-column>
                    <el-table-column prop="assetsid" width="140px" label="批次编号" align="center"></el-table-column>
                    <el-table-column prop="price" width="160px" label="单价" align="center"></el-table-column>
                    <el-table-column prop="count" width="160px" label="当前库存量" align="center"></el-table-column>
                    <el-table-column prop="handlerempname" width="180px" label="采购人" align="center"></el-table-column>
                    <el-table-column width="260px" label="领用操作" align="center">
                        <template slot-scope="scope">
                            <el-button type="success" plain @click="upd(scope.$index, scope.row)">领用</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <br>
                <br>
                <br>
                <el-table :data="normalList2" v-loading="loading" ref="normalList2" stripe>
                    <el-table-column prop="assetscode" width="160px" label="资产编号" align="center"></el-table-column>
                    <el-table-column prop="assetsnamecn" width="220px" label="资产名称" align="center"></el-table-column>
                    <el-table-column prop="assetsid" width="140px" label="批次编号" align="center"></el-table-column>
                    <el-table-column prop="price" width="160px" label="单价" align="center"></el-table-column>
                    <el-table-column prop="count" width="160px" label="当前库存量" align="center"></el-table-column>
                    <el-table-column prop="handlerempname" width="180px" label="采购人" align="center"></el-table-column>
                    <el-table-column width="260px" label="转移" align="center">
                        <template slot-scope="scope">
                            <el-button type="danger" plain @click="del(scope.$index, scope.row)">转移</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </el-main>
        </el-container>
    </div>
</template>

<script>
export default {
    name: "carTrans",
    data() {
        return {
            options: [{
                value: '1',
                label: '资产领用'
            }, {
                value: '2',
                label: '资产转移'
            }],
            value: '',
            normalList1: [],
            normal1: {
                dept: "",
                empno: "",
                id: "",
                namecn: "",
            },
            normalList2: [],
            normal2: {
                dept: "",
                empno: "",
                id: "",
                namecn: "",
            },
            myCar: "",
            loading: false,
        };
    },
    created() {
        this.postJsonCar()
        this.postJsonDl()
        this.postJsonNor();
    },
    methods: {
        postJsonCar() {
            // console.log("进入加载列表数据方法")
            var rul = "http://121.37.241.58:8883/logic/trans/normal/checkout/list"
            this.$axios.get(rul).then(re => {
                // console.log(re.data)
                this.normalList2 = re.data
            });
        },
        postJsonNor() {
            // console.log("进入加载列表数据方法")
            var rul = "http://121.37.241.58:8883/logic/trans/normal/checkin/list"
            this.$axios.get(rul).then(re => {
                // console.log(re.data)
                this.normalList1 = re.data
            });
        },
        postJsonDl() {
            console.log("进入加载下拉框数据方法")
            var rul = "http://121.37.241.58:8883/logic/trans/normal/2"
            this.$axios.post(rul).then(re => {
                console.log("-------")
                // console.log(re.data)
                this.myCar = re.data
                this.myCar.push({ powertype: "全部" })
            });
        },
        select() {
            console.log(this.car.powertype);
            console.log("进入数据搜索列表数据方法")
            // 默认查询接口
            var rul = "http://121.37.241.58:8883/logic/baseInfo/sysUser/find?namecn=1"

            // 根据下列选项除全部以外的信息查询接口
            if (this.user.role != "全部") {
                rul = "http://121.37.241.58:8883/logic/baseInfo/sysUser/find?role=" + this.user.role
            }

            this.$axios.get(rul).then(re => {
                console.log(re.data)
                this.UsersList = re.data
            });
        }
    }
}
</script>

<style scoped>
.header-all {
    padding: 0px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
</style>